package package004.section002

import fundation.gsonPrintln
import org.junit.Test

/**
 * @author futao
 * Created on 2017/11/16 - 15:14.
 */
class CompanionObject {
    private val name:String
    private val age:Int
    private fun say(){
        gsonPrintln("My name is $name , I am $age years old now.")
    }
    constructor(name:String,age:Int){
        this.name=name
        this.age=age
    }
    companion object {
        fun introductSelf(){
            gsonPrintln("My name is ${CompanionObject("aa",1).name} , I am years old now.")
            gsonPrintln(argument = "我被初始化了")
        }
    }
}
class TestClass{
    @Test
    fun testCase001(){
        val companionObject = CompanionObject(name = "name", age = 18)
        gsonPrintln(companionObject)
                
        CompanionObject.introductSelf()
    }
    /**
     * first Word CamelCase
     *
     */
    @Test
    fun testCase002(){

    }
    @Test
    fun testCase003(){
        val subUser=FacebookUser.newSubscribingUser("1185172056@qq.com")
        gsonPrintln(subUser.nickName)
    }
}


class FacebookUser private constructor(val nickName:String){
    companion object {
        fun newSubscribingUser(email:String)=
                FacebookUser(email.substringBefore("@"))

        fun newFacebookUser(accounrId:Int){
        }
    }
}


